/* ApplicationController */

//	Copyright (C) 2007 Christian Martick, http://juhu-mac.blogspot.com
//
//	Permission is hereby granted, free of charge, to any person obtaining a copy
//	of this software and associated documentation files (the "Software"), to deal
//	in the Software without restriction, including without limitation the rights
//	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//	copies of the Software, and to permit persons to whom the Software is
//	furnished to do so, subject to the following conditions:
//
//	The above copyright notice and this permission notice shall be included in
//	all copies or substantial portions of the Software.
//
//	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//	THE SOFTWARE.

#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
#import <Growl/Growl.h>
#import "smcJaikuAPI.h"
#import "smcJaikuHTML.h"
#import "smcWindow.h"
#import "smcRoundedFlatBox.h"
#import "smcScroller.h"
#import "smcUpdateCheck.h"

#include <Carbon/Carbon.h>

#define grNOTIFICATION_NEW_POST @"New Posts Received"
#define grNOTIFICATION_NEW_COMMENT @"New Comments Received"  

#define kSmcStatusTooltipNone @""
#define kSmcStatusTooltipNew @"new post"
#define kSmcStatusTooltipError @"jaiku update failed"

@interface ApplicationController : NSObject <GrowlApplicationBridgeDelegate, smcJaikuAPIDelegate>
{
	IBOutlet NSTextField *charsLeft;

	// delete when done with oauth
    IBOutlet NSForm *credential;
	
	IBOutlet NSTabView *credentialTabView;

    IBOutlet NSWindow *credWindow;
    IBOutlet WebView *htmlView;
    IBOutlet NSWindow *iconWindow;
    IBOutlet NSTextField *location;
    IBOutlet NSWindow *mainWindow;
    IBOutlet NSTextField *messageField;
    IBOutlet NSButton *plusIconButton;
    IBOutlet NSImageView *postIcon;
    IBOutlet NSWindow *prefWindow;
    IBOutlet NSButton *sendButton;
	IBOutlet NSTextField *fromLabel;
	IBOutlet NSBox *postBox; 
	
	NSStatusItem *statusItem;
	NSMutableSet *collapsedEntries;
	NSMutableSet *expandedEntries;
	NSMutableIndexSet *indexSet;
	NSString *streamSelector;
	BOOL doingUpdate;
	BOOL comment;
	int postIconIndex;
	NSPoint savedScrollPosition;
	
	NSURL *commentTo;
	
	EventHotKeyRef keyRef;
	
	NSTimer *theTimer;
	NSTimeInterval timerTime;

	smcJaikuAPI *jaiku;

	smcUpdateCheck *updateChecker;
	smcScroller *theScrollbar;
	
	BOOL growler;
}

//Actions
- (IBAction) changedTheme: (id) sender;
- (IBAction) showCredentials: (id) sender;
- (IBAction) doneCredential: (id) sender;

- (IBAction)showPrefs:(id)sender;
- (IBAction)donePrefs:(id)sender;

- (IBAction)showIcons: (id) sender;
- (IBAction)doneIcons: (id) sender;

- (IBAction) refreshClick: (id) sender;
- (IBAction) statusItemClick: (id) sender;
- (IBAction) quitClicked: (id) sender;
- (IBAction) sendMessage: (id) sender;
- (IBAction) jaikuClick: (id) sender;
- (IBAction) playSound: (id) sender;
- (IBAction) setupLoginStartup: (id) sender;
- (IBAction) hotkeySetup: (id) sender;

- (void) deletePostWithURLPathString: (NSString *) urlString andFragment: (NSString *) fragment;
- (void) commentToPostNumber: (int) index;
- (void) addContactWithNick: (NSString *) nick andFirst: (NSString *) first;

@end
